//=======================================================================
[!output COPYRIGHT_MSG]
//
//		File:	FPClasses.h
//
//		Date:	[!output FPDATE]
//
//		Desc:	Declaration of function plug-in classes.
//=======================================================================

#pragma once
#include "resource.h"       // main symbols

#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
#endif
[!if FUNCPACKAGE_NONNUMERIC]

//=======================================================================
// non-numeric parameter support
#define MAXSIZE_DATE_STR 20
#define MAXSIZE_CHAR_STR 256
typedef char DATE_STR[MAXSIZE_DATE_STR+1];
typedef char CHSTR[MAXSIZE_CHAR_STR+1];
EXTERN_C const IID IID_IDSSTime;
//=======================================================================
[!endif]

//=======================================================================
// [!output FUNCPACKAGE_CLASSNAME]
//=======================================================================
// [!output FUNCPACKAGE_INTERFACE]
[
	object,
	uuid("[!output FUNCPACKAGE_DEFINTERFACE_IID]"),
	dual,	helpstring("[!output FUNCPACKAGE_INTERFACE] Interface"),
	pointer_default(unique)
]
__interface [!output FUNCPACKAGE_INTERFACE] : IDispatch
{
};

// [!output FUNCPACKAGE_CLASSNAME]

[
	coclass,
	default([!output FUNCPACKAGE_INTERFACE]),
	threading(both),
	vi_progid("[!output FUNCPACKAGE_VIPROGID]"),
	progid("[!output FUNCPACKAGE_PROGID]"),
	version(1.0),
	uuid("[!output FUNCPACKAGE_COCLASS_IID]"),
	helpstring("[!output FUNCPACKAGE_SHORTNAME] Class")
]
class ATL_NO_VTABLE [!output FUNCPACKAGE_CLASSNAME] :
	public [!output FUNCPACKAGE_INTERFACE],
	public ICDSSFunctionPackage2
{
public:
	[!output FUNCPACKAGE_CLASSNAME]()
	{
	}
	~[!output FUNCPACKAGE_CLASSNAME]()
	{
	}

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
	// ICDSSFunctionPackage Methods
	STDMETHOD(Count)(int *pCount);
	STDMETHOD(get_CLSID)(GUID *pCLSID);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_Name)(BSTR *pName);
	STDMETHOD(get_Version)(BSTR *pVersion);
	STDMETHOD(Item)(int Index, ICDSSFunctionObject **ppFunctionObject);
	// ICDSSFunctionPackage2 Methods
	STDMETHOD(get_CLSIDString)(BSTR *pCLSIDString);
	STDMETHOD(get_FunctionName)(int Index, BSTR *pName);
};
[!if FUNCSIM_COUNT]

//=======================================================================
// [!output FUNCSIM_CLASSNAME]
//=======================================================================
// [!output FUNCSIM_INTERFACE]
[
	object,
	uuid("[!output FUNCSIM_DEFINTERFACE_IID]"),
	dual,	helpstring("[!output FUNCSIM_INTERFACE] Interface"),
	pointer_default(unique)
]
__interface [!output FUNCSIM_INTERFACE] : IDispatch
{
};

// [!output FUNCSIM_CLASSNAME]

[
	coclass,
	default([!output FUNCSIM_INTERFACE]),
	threading(both),
	vi_progid("[!output FUNCSIM_VIPROGID]"),
	progid("[!output FUNCSIM_PROGID]"),
	version(1.0),
	uuid("[!output FUNCSIM_COCLASS_IID]"),
	helpstring("[!output FUNCSIM_SHORTNAME] Class")
]
class ATL_NO_VTABLE [!output FUNCSIM_CLASSNAME] :
	public [!output FUNCSIM_INTERFACE],
	public ICDSSFunctionObject2,
	public ICDSSSimpleFunction
{
public:
	[!output FUNCSIM_CLASSNAME]();
	~[!output FUNCSIM_CLASSNAME]();

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
	STDMETHOD(Init)(int lFunctionIndex);
	// ICDSSFunctionObject Methods
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(int Index, VARIANT *pValue);
	// ICDSSFunctionObject2 Methods
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(int *pInCount, int *pOutCount, int *pRepeatCount);
	STDMETHOD(get_ParamInfo)(int ParamIndex, int InParameter, BSTR *pName, EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(int *pCount);
	STDMETHOD(get_PropertyInfo)(int PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
	// ICDSSSimpleFunction Methods
	STDMETHOD(Calculate)(int nParam, double *pParam, double *pResult, DSSData_Flags *pFlag);
	STDMETHOD(CalculateRepeat)(int nParam, int nRepeat, double **pParam, double *pResult,
		DSSData_Flags *pFlag);

private:
	Int32 m_lFunctionIndex;
[!loop = FUNCSIM_COUNT]
[!if FUNCSIM_PROPVARS]
[!output OUTPUT_DIRECTIVE] FUNCSIM_PROPVARS_[!output LOOP_COUNTER]]
[!endif][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCSIM_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCSIM_FUNCNAME_[!output LOOP_COUNTER]])(Int32 nParam, double *pParam, double *pResult, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCNNSIM_COUNT]

//=======================================================================
// [!output FUNCNNSIM_CLASSNAME]
//=======================================================================
// [!output FUNCNNSIM_INTERFACE]
[
	object,
	uuid("[!output FUNCNNSIM_DEFINTERFACE_IID]"),
	dual,	helpstring("[!output FUNCNNSIM_INTERFACE] Interface"),
	pointer_default(unique)
]
__interface [!output FUNCNNSIM_INTERFACE] : IDispatch
{
};

// [!output FUNCNNSIM_CLASSNAME]

[
	coclass,
	default([!output FUNCNNSIM_INTERFACE]),
	threading(both),
	vi_progid("[!output FUNCNNSIM_VIPROGID]"),
	progid("[!output FUNCNNSIM_PROGID]"),
	version(1.0),
	uuid("[!output FUNCNNSIM_COCLASS_IID]"),
	helpstring("[!output FUNCNNSIM_SHORTNAME] Class")
]
class ATL_NO_VTABLE [!output FUNCNNSIM_CLASSNAME] :
	public [!output FUNCNNSIM_INTERFACE],
	public ICDSSFunctionObject2,
	public ICDSSNNSimpleFunction
{
public:
	[!output FUNCNNSIM_CLASSNAME]();
	~[!output FUNCNNSIM_CLASSNAME]();

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int32 *pInCount, Int32 *pOutCount, Int32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int32 ParamIndex, Int32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSNNSimpleFuntion
	STDMETHOD(Calculate)(Int32 nParam, VARIANT *pParam, VARIANT *pResult, DSSData_Flags *pFlag);
	STDMETHOD(CalculateRepeat)(Int32 nParam, Int32 nRepeat, VARIANT *pParam, VARIANT *pResult, DSSData_Flags *pFlag);
	STDMETHOD(GetOutputType)(Int32 nSize, enum EnumDSSDataType *InputType, enum EnumDSSDataType *OutputType);
	STDMETHOD(Init)(Int32 lFunctionIndex);
// support functions
	STDMETHOD(ConvertFromVariant)(VARIANT *pVar, enum EnumDSSDataType iType, BYTE *pData);
	STDMETHOD(getParamFromVariant)(VARIANT *pParam, Int32 index, enum EnumDSSDataType type, BYTE *outResult);
private:
	Int32 m_lFunctionIndex;
[!loop = FUNCNNSIM_COUNT]
[!if FUNCNNSIM_PROPVARS]
[!output OUTPUT_DIRECTIVE] FUNCNNSIM_PROPVARS_[!output LOOP_COUNTER]]
[!endif][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCNNSIM_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCNNSIM_FUNCNAME_[!output LOOP_COUNTER]])(Int32 nParam, VARIANT *pParam, VARIANT *pResult, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCGEN_COUNT]

//=======================================================================
// [!output FUNCGEN_CLASSNAME]
//=======================================================================
// [!output FUNCGEN_INTERFACE]
[
	object,
	uuid("[!output FUNCGEN_DEFINTERFACE_IID]"),
	dual,	helpstring("[!output FUNCGEN_INTERFACE] Interface"),
	pointer_default(unique)
]
__interface [!output FUNCGEN_INTERFACE] : IDispatch
{
};

// [!output FUNCGEN_CLASSNAME]

[
	coclass,
	default([!output FUNCGEN_INTERFACE]),
	threading(both),
	vi_progid("[!output FUNCGEN_VIPROGID]"),
	progid("[!output FUNCGEN_PROGID]"),
	version(1.0),
	uuid("[!output FUNCGEN_COCLASS_IID]"),
	helpstring("[!output FUNCGEN_SHORTNAME] Class")
]
class ATL_NO_VTABLE [!output FUNCGEN_CLASSNAME] :
	public [!output FUNCGEN_INTERFACE],
	public ICDSSFunctionObject2,
	public ICDSSGenericFunction
{
public:
	[!output FUNCGEN_CLASSNAME]();
	~[!output FUNCGEN_CLASSNAME]();

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int32 *pInCount, Int32 *pOutCount, Int32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int32 ParamIndex, Int32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSGenericFunction
	STDMETHOD(Calculate)();
	STDMETHOD(GetOutput)(Int32 nSize, Int32 *nDataSize, double *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetOutputType)(EnumDSSParameterType * pType);
	STDMETHOD(SetInputParam)(Int32 nParamIndex, Int32 nSize, double *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetInputParamType)(Int32 nParamIndex, EnumDSSParameterType *pType);
	STDMETHOD(Clear)();
	STDMETHOD(IsNullProcessable)(VARIANT_BOOL *pCanProcessNULL)
	{
		if (pCanProcessNULL == NULL)
			return E_POINTER;
			
		*pCanProcessNULL = VARIANT_TRUE;

		return S_OK;
	}
	STDMETHOD(Init)(Int32 lFunctionIndex);
private:
	Int32 m_lFunctionIndex;		// current function index
[!if FUNCGEN_VECTOR_INPUT != ""]
	Int32 m_lInputSize;			// number of input rows
[!endif]
	Int32 m_lRepeatCnt;			// number of input columns for last repeated input
[!loop = FUNCGEN_COUNT]
	// [!output OUTPUT_DIRECTIVE] FUNCGEN_FUNCNAME_[!output LOOP_COUNTER]] parameters
[!output OUTPUT_DIRECTIVE] FUNCGEN_INPARAMDECLS_[!output LOOP_COUNTER]]
[!if FUNCGEN_PROPVARS]
[!output OUTPUT_DIRECTIVE] FUNCGEN_PROPVARS_[!output LOOP_COUNTER]]
[!endif][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCGEN_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCGEN_FUNCNAME_[!output LOOP_COUNTER]])(Int32 nSize, Int32 *nDataSize, double *pData, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCNNGEN_COUNT]

//=======================================================================
// [!output FUNCNNGEN_CLASSNAME]
//=======================================================================
// [!output FUNCNNGEN_INTERFACE]
[
	object,
	uuid("[!output FUNCNNGEN_DEFINTERFACE_IID]"),
	dual,	helpstring("[!output FUNCNNGEN_INTERFACE] Interface"),
	pointer_default(unique)
]
__interface [!output FUNCNNGEN_INTERFACE] : IDispatch
{
};

// [!output FUNCNNGEN_CLASSNAME]

[
	coclass,
	default([!output FUNCNNGEN_INTERFACE]),
	threading(both),
	vi_progid("[!output FUNCNNGEN_VIPROGID]"),
	progid("[!output FUNCNNGEN_PROGID]"),
	version(1.0),
	uuid("[!output FUNCNNGEN_COCLASS_IID]"),
	helpstring("[!output FUNCNNGEN_SHORTNAME] Class")
]
class ATL_NO_VTABLE [!output FUNCNNGEN_CLASSNAME] :
	public [!output FUNCNNGEN_INTERFACE],
	public ICDSSFunctionObject2,
	public ICDSSNNGenericFunction
{
public:
	[!output FUNCNNGEN_CLASSNAME]();
	~[!output FUNCNNGEN_CLASSNAME]();

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int32 *pInCount, Int32 *pOutCount, Int32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int32 ParamIndex, Int32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSNNGenericFunction
	STDMETHOD(Calculate)();
	STDMETHOD(GetOutput)(Int32 nSize, Int32 *nDataSize, VARIANT *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetOutputType)(Int32 nSize, EnumDSSDataType *pInputType, EnumDSSDataType *pOutputDataType, EnumDSSParameterType *pOutputParamType);
	STDMETHOD(SetInputParam)(Int32 nParamIndex, Int32 nSize, EnumDSSDataType dataType, VARIANT *pData, DSSData_Flags *pFlag);
	STDMETHOD(GetInputParamType)(Int32 nParamIndex, EnumDSSParameterType *pType);
	STDMETHOD(Clear)();
	STDMETHOD(IsNullProcessable)(VARIANT_BOOL * pCanProcessNULL)
	{
		if (pCanProcessNULL == NULL)
			return E_POINTER;
			
		*pCanProcessNULL = VARIANT_FALSE;

		return S_OK;
	}
	STDMETHOD(Init)(Int32 lFunctionIndex);
// support functions
	STDMETHOD(ConvertFromVariant)(VARIANT *pVar, enum EnumDSSDataType iType, BYTE *pData);
	STDMETHOD(getParamFromVariant)(VARIANT *pParam, Int32 index, enum EnumDSSDataType type, BYTE *outResult);
private:
	Int32 m_lFunctionIndex;		// current function index
[!if FUNCNNGEN_VECTOR_INPUT != ""]
	Int32 m_lInputSize;			// number of input rows
[!endif]
	Int32 m_lRepeatCnt;			// number of input columns for last repeated input
[!loop = FUNCNNGEN_COUNT]
	// [!output OUTPUT_DIRECTIVE] FUNCNNGEN_FUNCNAME_[!output LOOP_COUNTER]] parameters
[!output OUTPUT_DIRECTIVE] FUNCNNGEN_INPARAMDECLS_[!output LOOP_COUNTER]]
[!if FUNCNNGEN_PROPVARS]
[!output OUTPUT_DIRECTIVE] FUNCNNGEN_PROPVARS_[!output LOOP_COUNTER]]
[!endif][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCNNGEN_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCNNGEN_FUNCNAME_[!output LOOP_COUNTER]])(Int32 nSize, Int32 *nDataSize, VARIANT *pData, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
[!if FUNCAGG_COUNT]

//=======================================================================
// [!output FUNCAGG_CLASSNAME]
//=======================================================================
// [!output FUNCAGG_INTERFACE]
[
	object,
	uuid("[!output FUNCAGG_DEFINTERFACE_IID]"),
	dual,	helpstring("[!output FUNCAGG_INTERFACE] Interface"),
	pointer_default(unique)
]
__interface [!output FUNCAGG_INTERFACE] : IDispatch
{
};

// [!output FUNCAGG_CLASSNAME]

[
	coclass,
	default([!output FUNCAGG_INTERFACE]),
	threading(both),
	vi_progid("[!output FUNCAGG_VIPROGID]"),
	progid("[!output FUNCAGG_PROGID]"),
	version(1.0),
	uuid("[!output FUNCAGG_COCLASS_IID]"),
	helpstring("[!output FUNCAGG_SHORTNAME] Class")
]
class ATL_NO_VTABLE [!output FUNCAGG_CLASSNAME] :
	public [!output FUNCAGG_INTERFACE],
	public ICDSSFunctionObject2,
	public ICDSSAggregationFunction
{
public:
	[!output FUNCAGG_CLASSNAME]();
	~[!output FUNCAGG_CLASSNAME]();

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

public:
// ICDSSFunctionObject2
	STDMETHOD(get_FunctionType)(EnumDSSFunctionType *pType);
	STDMETHOD(SetProperty)(Int32 Index, VARIANT *pValue);
	STDMETHOD(get_Description)(BSTR *pDescription);
	STDMETHOD(get_ParamCount)(Int32 *pInCount, Int32 *pOutCount, Int32 *pRepeatCount);
	STDMETHOD(get_ParamInfo)(Int32 ParamIndex, Int32 InParameter, BSTR *pName, enum EnumDSSParameterType *pType);
	STDMETHOD(get_SqlType)(enum EnumDSSFunctionSQLType *pSqlType);
	STDMETHOD(get_PropertyCount)(Int32 *pCount);
	STDMETHOD(get_PropertyInfo)(Int32 PropertyIndex, BSTR *pName, BSTR *pDescription, VARIANT *pValue);
// ICDSSAggregationFunction
	STDMETHOD(Calculate)(Int32 nSize, double *pVec, double *pResult, DSSData_Flags *pFlag);
	STDMETHOD(CalculateRepeat)(Int32 nSize, Int32 nRepeat, Int32 *pStartPoint, double *pVec, DOUBLE *opResult, DSSData_Flags *pFlag);
	STDMETHOD(Init)(Int32 lFunctionIndex);
private:
	Int32 m_lFunctionIndex;
[!loop = FUNCAGG_COUNT]
[!if FUNCAGG_PROPVARS]
[!output OUTPUT_DIRECTIVE] FUNCAGG_PROPVARS_[!output LOOP_COUNTER]]
[!endif][!endloop]
	// TODO: add any member variables required by your function plug-in(s)

[!loop = FUNCAGG_COUNT]	STDMETHOD([!output OUTPUT_DIRECTIVE] FUNCAGG_FUNCNAME_[!output LOOP_COUNTER]])(Int32 nSize, double *pVec, double *pResult, DSSData_Flags *pFlag);
[!endloop]};
[!endif]
